<template>
  <div class="search1">
    <div class="tbox">
      <div class="ttext">
        <div class="timg">
          <img class="auto-img aimg" src="../assets/home_active.png" alt="" />
        </div>
        <div class="ding" @click="goDing()">
          <div class="tcon">{{ data1.nm }}</div>
          <div class="san">
            <img class="auto-img" src="../assets/s1.png" alt="" />
          </div>
        </div> 
      </div>
      <div class="search">
        <van-search
          v-model="value"
          shape="round"
          background="#fff"
          placeholder="请输入电影名称"
          @focus="goSripe()"
        />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Search",
  data() {
    return {
      value: "",
      data1: {
        id: "20",
        nm: "广州",
      },
    };
  },
  created() {
    // //获取本地存储的聊天记录
    let localData = localStorage.getItem("data");
    

    if (!localData) {
      localData = [];
    } else {
      localData = JSON.parse(localData);
      if (localData.length > 1) {
        this.data1 = localData[localData.length - 1];
      } else if (localData[localData.length - 1] === "undefined") {
        this.data1.id = "20";
        this.data1.nm = "广州";
      }
    }
    if (localData.length > 1) {
      return;
    } else {
      let addList = {
        id: "20",
        nm: "广州",
      };
      localData.push(addList);
      localStorage.setItem("data", JSON.stringify(localData));
    }

    // let localData = JSON.parse(localStorage.getItem("data") || "{}");
  },
  methods: {
    goDing() {
      this.$router.push({ name: "City" });
    },
    goSripe(){
      this.$router.push({ name: "Sripe" });
    }
  },
};
</script>

<style lang="less" scoped>
.tbox {
  display: flex;
  padding: 0 10px;
  box-sizing: border-box;
  background-color: #fff;
  .aimg{
    width: 20px;
    height: 20px;
  }
  .ttext {
    width: 25%;
    height: 54px;
    text-align: center;
    line-height: 54px;
    display: flex;
    align-items: center;
    .timg {
      width: 20px;
      height: 20px;
      margin-right: 5px;
      margin-left: 10px;
    }
    .ding {
      display: flex;
      align-items: center;
      .tcon{
        width: 30px;
      }
      .san {
        width: 10px;
        height: 10px;
        margin-left: 2px;
      }
    }
  }
  .search {
    width: 75%;
    height: 54px;
  }
}
</style>